<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>tango.util.container.Container</title>
  <link href="./css/style.css" rel="stylesheet" type="text/css"/>
  <!-- <link href="./img/icon.png" rel="icon" type="image/png"/> -->
  <script type="text/javascript" src="./js/jquery.js"></script>
  <script type="text/javascript" src="./js/modules.js"></script>
  <script type="text/javascript" src="./js/quicksearch.js"></script>
  <script type="text/javascript" src="./js/navigation.js"></script>
  <!--<script type="text/javascript" src="./js/jquery.treeview.js"></script>-->
  <script type="text/javascript">
    var g_moduleFQN = "tango.util.container.Container";
  </script>
  
</head>
<body>
<div id="content">
  <h1><a href="./htmlsrc/tango.util.container.Container.html" class="symbol">tango.util.container.Container</a></h1>
  
<p class="sec_header">License:</p>BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a>
<p class="sec_header">Version:</p>Apr 2008: Initial release
<p class="sec_header">Authors:</p>Kris
<p class="sec_header">Since:</p>0.99.7
<dl>
<dt class="decl">struct <a class="symbol _struct" name="Container" href="./htmlsrc/tango.util.container.Container.html#L27" kind="struct" beg="27" end="411">Container</a>; <a title="Permalink to this symbol" href="#Container" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L27">#</a></dt>
<dd class="ddef">
<div class="summary">Utility functions and constants</div>
<dl>
<dt class="decl">int <a class="symbol _variable" name="Container.defaultInitialBuckets" href="./htmlsrc/tango.util.container.Container.html#L35" kind="variable" beg="35" end="35">defaultInitialBuckets</a>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#Container.defaultInitialBuckets" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L35">#</a></dt>
<dd class="ddef">
<div class="summary">default initial number of buckets of a non-empty hashmap</div></dd>
<dt class="decl">float <a class="symbol _variable" name="Container.defaultLoadFactor" href="./htmlsrc/tango.util.container.Container.html#L45" kind="variable" beg="45" end="45">defaultLoadFactor</a>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#Container.defaultLoadFactor" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L45">#</a></dt>
<dd class="ddef">
<div class="summary">default load factor for a non-empty hashmap. The hash 
                table is resized when the proportion of elements per 
                buckets exceeds this limit</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.reap" href="./htmlsrc/tango.util.container.Container.html#L53" kind="function" beg="53" end="53">reap</a><span class="tparams">(V)</span><span class="params">(V <em>v</em>)</span>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#Container.reap" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L53">#</a></dt>
<dd class="ddef">
<div class="summary">generic value reaper, which does nothing</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.reap:2" href="./htmlsrc/tango.util.container.Container.html#L61" kind="function" beg="61" end="61">reap</a><span class="tparams">(K, V)</span><span class="params">(K <em>k</em>, V <em>v</em>)</span>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#Container.reap:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L61">#</a></dt>
<dd class="ddef">
<div class="summary">generic key/value reaper, which does nothing</div></dd>
<dt class="decl">uint <a class="symbol _function" name="Container.hash" href="./htmlsrc/tango.util.container.Container.html#L70" kind="function" beg="70" end="80">hash</a><span class="tparams">(K)</span><span class="params">(K <em>k</em>, uint <em>length</em>)</span>; <span class="attrs">[<span class="stc">static</span>]</span> <a title="Permalink to this symbol" href="#Container.hash" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L70">#</a></dt>
<dd class="ddef">
<div class="summary">generic hash function, using the default hashing. Thanks
                to 'mwarning' for the optimization suggestion</div></dd>
<dt class="decl">struct <a class="symbol _struct" name="Container.Collect" href="./htmlsrc/tango.util.container.Container.html#L88" kind="struct" beg="88" end="151">Collect</a><span class="tparams">(T)</span>; <a title="Permalink to this symbol" href="#Container.Collect" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L88">#</a></dt>
<dd class="ddef">
<div class="summary">generic GC allocation manager</div>
<dl>
<dt class="decl">T* <a class="symbol _function" name="Container.Collect.allocate" href="./htmlsrc/tango.util.container.Container.html#L96" kind="function" beg="96" end="99">allocate</a><span class="params">()</span>; <a title="Permalink to this symbol" href="#Container.Collect.allocate" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L96">#</a></dt>
<dd class="ddef">
<div class="summary">allocate a T sized memory chunk</div></dd>
<dt class="decl">T*[] <a class="symbol _function" name="Container.Collect.allocate:2" href="./htmlsrc/tango.util.container.Container.html#L107" kind="function" beg="107" end="110">allocate</a><span class="params">(uint <em>count</em>)</span>; <a title="Permalink to this symbol" href="#Container.Collect.allocate:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L107">#</a></dt>
<dd class="ddef">
<div class="summary">allocate an array of T sized memory chunks</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Collect.collect" href="./htmlsrc/tango.util.container.Container.html#L118" kind="function" beg="118" end="122">collect</a><span class="params">(T* <em>p</em>)</span>; <a title="Permalink to this symbol" href="#Container.Collect.collect" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L118">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T[] is discarded</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Collect.collect:2" href="./htmlsrc/tango.util.container.Container.html#L130" kind="function" beg="130" end="134">collect</a><span class="params">(T*[] <em>t</em>)</span>; <a title="Permalink to this symbol" href="#Container.Collect.collect:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L130">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T[] is discarded</div></dd>
<dt class="decl">bool <a class="symbol _function" name="Container.Collect.collect:3" href="./htmlsrc/tango.util.container.Container.html#L147" kind="function" beg="147" end="150">collect</a><span class="params">(bool <em>all</em> = true)</span>; <a title="Permalink to this symbol" href="#Container.Collect.collect:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L147">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls</div></dd></dl></dd>
<dt class="decl">struct <a class="symbol _struct" name="Container.Malloc" href="./htmlsrc/tango.util.container.Container.html#L175" kind="struct" beg="175" end="238">Malloc</a><span class="tparams">(T)</span>; <a title="Permalink to this symbol" href="#Container.Malloc" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L175">#</a></dt>
<dd class="ddef">
<div class="summary">Malloc allocation manager.</div>
Note that, due to GC behaviour, you should not configure
                a custom allocator for containers holding anything managed
                by the GC. For example, you cannot use a MallocAllocator
                to manage a container of classes or strings where those 
                were allocated by the GC. Once something is owned by a GC
                then it's lifetime must be managed by GC-managed entities
                (otherwise the GC may think there are no live references
                and prematurely collect container contents).
        
                You can explicity manage the collection of keys and values
                yourself by providing a reaper delegate. For example, if 
                you use a MallocAllocator to manage key/value pairs which
                are themselves allocated via malloc, then you should also
                provide a reaper delegate to collect those as required.
<dl>
<dt class="decl">T* <a class="symbol _function" name="Container.Malloc.allocate" href="./htmlsrc/tango.util.container.Container.html#L183" kind="function" beg="183" end="186">allocate</a><span class="params">()</span>; <a title="Permalink to this symbol" href="#Container.Malloc.allocate" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L183">#</a></dt>
<dd class="ddef">
<div class="summary">allocate an array of T sized memory chunks</div></dd>
<dt class="decl">T*[] <a class="symbol _function" name="Container.Malloc.allocate:2" href="./htmlsrc/tango.util.container.Container.html#L194" kind="function" beg="194" end="197">allocate</a><span class="params">(uint <em>count</em>)</span>; <a title="Permalink to this symbol" href="#Container.Malloc.allocate:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L194">#</a></dt>
<dd class="ddef">
<div class="summary">allocate an array of T sized memory chunks</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Malloc.collect" href="./htmlsrc/tango.util.container.Container.html#L205" kind="function" beg="205" end="209">collect</a><span class="params">(T*[] <em>t</em>)</span>; <a title="Permalink to this symbol" href="#Container.Malloc.collect" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L205">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T[] is discarded</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Malloc.collect:2" href="./htmlsrc/tango.util.container.Container.html#L217" kind="function" beg="217" end="221">collect</a><span class="params">(T* <em>p</em>)</span>; <a title="Permalink to this symbol" href="#Container.Malloc.collect:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L217">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T[] is discarded</div></dd>
<dt class="decl">bool <a class="symbol _function" name="Container.Malloc.collect:3" href="./htmlsrc/tango.util.container.Container.html#L234" kind="function" beg="234" end="237">collect</a><span class="params">(bool <em>all</em> = true)</span>; <a title="Permalink to this symbol" href="#Container.Malloc.collect:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L234">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls</div></dd></dl></dd>
<dt class="decl">struct <a class="symbol _struct" name="Container.Chunk" href="./htmlsrc/tango.util.container.Container.html#L267" kind="struct" beg="267" end="410">Chunk</a><span class="tparams">(T)</span>; <a title="Permalink to this symbol" href="#Container.Chunk" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L267">#</a></dt>
<dd class="ddef">
<div class="summary">Chunk allocator</div>
Can save approximately 30% memory for small elements (tested 
                with integer elements and a chunk size of 1000), and is at 
                least twice as fast at adding elements when compared to the 
                default allocator (approximately 50x faster with LinkedList)
        
                Note that, due to GC behaviour, you should not configure
                a custom allocator for containers holding anything managed
                by the GC. For example, you cannot use a MallocAllocator
                to manage a container of classes or strings where those 
                were allocated by the GC. Once something is owned by a GC
                then it's lifetime must be managed by GC-managed entities
                (otherwise the GC may think there are no live references
                and prematurely collect container contents).
        
                You can explicity manage the collection of keys and values
                yourself by providing a reaper delegate. For example, if 
                you use a MallocAllocator to manage key/value pairs which
                are themselves allocated via malloc, then you should also
                provide a reaper delegate to collect those as required.
<dl>
<dt class="decl">void <a class="symbol _function" name="Container.Chunk.config" href="./htmlsrc/tango.util.container.Container.html#L288" kind="function" beg="288" end="296">config</a><span class="params">(int <em>chunks</em>, int <em>presize</em>)</span>; <a title="Permalink to this symbol" href="#Container.Chunk.config" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L288">#</a></dt>
<dd class="ddef">
<div class="summary">set the chunk size and preallocate lists</div></dd>
<dt class="decl">T* <a class="symbol _function" name="Container.Chunk.allocate" href="./htmlsrc/tango.util.container.Container.html#L304" kind="function" beg="304" end="317">allocate</a><span class="params">()</span>; <a title="Permalink to this symbol" href="#Container.Chunk.allocate" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L304">#</a></dt>
<dd class="ddef">
<div class="summary">allocate an array of T sized memory chunks</div></dd>
<dt class="decl">T*[] <a class="symbol _function" name="Container.Chunk.allocate:2" href="./htmlsrc/tango.util.container.Container.html#L325" kind="function" beg="325" end="328">allocate</a><span class="params">(uint <em>count</em>)</span>; <a title="Permalink to this symbol" href="#Container.Chunk.allocate:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L325">#</a></dt>
<dd class="ddef">
<div class="summary">allocate an array of T sized memory chunks</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Chunk.collect" href="./htmlsrc/tango.util.container.Container.html#L336" kind="function" beg="336" end="340">collect</a><span class="params">(T*[] <em>t</em>)</span>; <a title="Permalink to this symbol" href="#Container.Chunk.collect" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L336">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T[] is discarded</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Chunk.collect:2" href="./htmlsrc/tango.util.container.Container.html#L348" kind="function" beg="348" end="357">collect</a><span class="params">(T* <em>p</em>)</span>; <a title="Permalink to this symbol" href="#Container.Chunk.collect:2" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L348">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when a specific T is discarded</div></dd>
<dt class="decl">bool <a class="symbol _function" name="Container.Chunk.collect:3" href="./htmlsrc/tango.util.container.Container.html#L370" kind="function" beg="370" end="381">collect</a><span class="params">(bool <em>all</em> = true)</span>; <a title="Permalink to this symbol" href="#Container.Chunk.collect:3" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L370">#</a></dt>
<dd class="ddef">
<div class="summary">Invoked when clear/reset is called on the host. 
                        This is a shortcut to clear everything allocated.
        
                        Should return true if supported, or false otherwise. 
                        False return will cause a series of discrete collect
                        calls</div></dd>
<dt class="decl">void <a class="symbol _function" name="Container.Chunk.newlist" href="./htmlsrc/tango.util.container.Container.html#L389" kind="function" beg="389" end="398">newlist</a><span class="params">()</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#Container.Chunk.newlist" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L389">#</a></dt>
<dd class="ddef">
<div class="summary">list manager</div></dd>
<dt class="decl">T[] <a class="symbol _function" name="Container.Chunk.block" href="./htmlsrc/tango.util.container.Container.html#L406" kind="function" beg="406" end="409">block</a><span class="params">()</span>; <span class="attrs">[<span class="prot">private</span>]</span> <a title="Permalink to this symbol" href="#Container.Chunk.block" class="symlink">¶</a><a title="Go to the HTML source file" class="srclink" href="./htmlsrc/tango.util.container.Container.html#L406">#</a></dt>
<dd class="ddef">
<div class="summary">list allocator</div></dd></dl></dd></dl></dd></dl>
</div>
<div id="footer">
  <p>Copyright (c) 2008 Kris Bell. All rights reserved</p>
  <p>Page generated by <a href="http://code.google.com/p/dil">dil</a> on Fri Dec 26 04:04:07 2008. Rendered by <a href="http://code.google.com/p/dil/wiki/Kandil">kandil</a>.</p>
</div>
</body>
</html>